<?php

class Silk_Tms_Helper_Status extends Mage_Core_Helper_Abstract
{
    const STATUS_ORDER_NEW = 'new';
    const STATUS_ORDER_PROCESSING = 'processing';
    const STATUS_ORDER_PICKED = 'picked';
    const STATUS_ORDER_DELIVERING = 'delivering';
    const STATUS_ORDER_DELIVERED = 'delivered';
    const STATUS_ORDER_COMPLETED = 'complete_order';
    //add by wanglin start
    const STATUS_ORDER_CLOSED = 'closed';
    //add by wanglin end

    const STATUS_SHIPPING_NEW = 'new';
    const STATUS_SHIPPING_ASSIGNED = 'assigned';
    const STATUS_SHIPPING_DELIVERING = 'delivering';
    const STATUS_SHIPPING_DELIVERED = 'delivered';
    const STATUS_SHIPPING_CANCELED = 'canceled';
    const STATUS_SHIPPING_SORTED = 'sorted';

    const MAGENTO_STATUS_PENDING = 'pending';
    const MAGENTO_STATUS_PROCESSING = 'processing';
    const MAGENTO_STATUS_COMPLETE_DELIVERING = 'complete_delivering';
    const MAGENTO_STATUS_COMPLETE_SHIP = 'complete_ship';
    const MAGENTO_STATUS_COMPLETE_ORDER = 'complete_order';

    public function getStatus($code, $type = 'order')
    {
        $status = array(
            self::STATUS_ORDER_NEW . '_order' => '已处理',
            self::STATUS_ORDER_PROCESSING . '_order' => '未取货',
            self::STATUS_ORDER_PICKED . '_order' => '已取货',
            self::STATUS_ORDER_DELIVERING . '_order' => '配送中',
            self::STATUS_ORDER_DELIVERED . '_order' => '配送完成',
            self::STATUS_ORDER_COMPLETED . '_order' => '订单完成',
        	//add by wanglin start
        	self::STATUS_ORDER_CLOSED . '_order' => '关闭',
        	//add by wanglin end
        	
            self::STATUS_SHIPPING_NEW . '_shipping' => '未分配',
            self::STATUS_SHIPPING_ASSIGNED . '_shipping' => '已分配',
            self::STATUS_SHIPPING_DELIVERING . '_shipping' => '配送中',
            self::STATUS_SHIPPING_DELIVERED . '_shipping' => '配送完成',
            self::STATUS_SHIPPING_CANCELED . '_shipping' => '已取消',
            self::STATUS_SHIPPING_SORTED . '_shipping' => '分拣完成',

            self::MAGENTO_STATUS_PENDING . '_magento' => '待处理',
            self::MAGENTO_STATUS_PROCESSING . '_magento' => '正在处理',
            self::MAGENTO_STATUS_COMPLETE_DELIVERING . '_magento' => '配送中',
            self::MAGENTO_STATUS_COMPLETE_SHIP . '_magento' => '配送完成',
            self::MAGENTO_STATUS_COMPLETE_ORDER . '_magento' => '已完成',
        );

        switch ($type) {
            case 'order':
                if (isset($status[$code . '_order'])) {
                    return $status[$code . '_order'];
                }
                break;
            case 'shipping':
                if (isset($status[$code . '_shipping'])) {
                    return $status[$code . '_shipping'];
                }
                break;
            case 'magento':
                if (isset($status[$code . '_magento'])) {
                    return $status[$code . '_magento'];
                }
                break;
        }

        return false;
    }

    public function getShippingStatusOptions()
    {
        return array(
            self::STATUS_SHIPPING_NEW => '未分配',
            self::STATUS_SHIPPING_ASSIGNED => '已分配',
            self::STATUS_SHIPPING_SORTED => '分拣完成',
            self::STATUS_SHIPPING_DELIVERING => '配送中',
            self::STATUS_SHIPPING_DELIVERED => '配送完成',
            self::STATUS_SHIPPING_CANCELED => '已取消',
        );
    }
}